import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CateBrandVO, CateBrandForm, CateBrandQuery } from '@/api/mall/cateBrand/types';

/**
 * 查询分类品牌列表
 * @param query
 * @returns {*}
 */

export const listCateBrand = (query?: CateBrandQuery): AxiosPromise<CateBrandVO[]> => {
  return request({
    url: '/mall/cateBrand/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询分类品牌详细
 * @param id
 */
export const getCateBrand = (id: string | number): AxiosPromise<CateBrandVO> => {
  return request({
    url: '/mall/cateBrand/' + id,
    method: 'get'
  });
};
/**
 * 根据分类ID查询品牌
 * @param id
 */
export const getBrandApi = (id: string | number): AxiosPromise<CateBrandVO> => {
  return request({
    url: '/mall/cateBrand/findBrandByCateId/' + id,
    method: 'get'
  });
};

/**
 * 新增分类品牌
 * @param data
 */
export const addCateBrand = (data: CateBrandForm) => {
  return request({
    url: '/mall/cateBrand',
    method: 'post',
    data: data
  });
};

/**
 * 修改分类品牌
 * @param data
 */
export const updateCateBrand = (data: CateBrandForm) => {
  return request({
    url: '/mall/cateBrand',
    method: 'put',
    data: data
  });
};

/**
 * 删除分类品牌
 * @param id
 */
export const delCateBrand = (id: string | number | Array<string | number>) => {
  return request({
    url: '/mall/cateBrand/' + id,
    method: 'delete'
  });
};
